//
//  YahooCurrencyExchangeHtmlCollector.m
//  MarketDataColloctor
//
//  Created by jiro on 10/03/11.
//  Copyright 2010 jiro music. All rights reserved.
//

#import "YahooCurrencyExchangeHtmlCollector.h"
#import "../../../Commons/MarketJaDbOperator.h"
#import "DbTypes.h"

@implementation YahooCurrencyExchangeHtmlCollector

//- (NSURL*) buildWebPageAddressFromYear: (int) yearFrom month: (int) monthFrom day: (int) dayFrom 
//	toYear: (int) yearTo month: (int) monthTo day: (int) dayTo andCode: (NSString*) code
- (NSURL*) buildWebPageAddressFromYear: (int) yearFrom month: (int) monthFrom day: (int) dayFrom 
	toYear: (int) yearTo month: (int) monthTo day: (int) dayTo andCode0: (NSString*) code0 code1: (NSString*) code1
{
	NSMutableString* urlExcapedCode = [ NSMutableString stringWithFormat: @"%@%@", code0, code1 ];
	[ urlExcapedCode appendString: @"%3DX" ];
	NSString* s = [ NSString stringWithFormat:
		@"http://info.finance.yahoo.co.jp//history/?code=%@&sy=%d&sm=%d&sd=%d&ey=%d&em=%d&ed=%d&tm=d",
		urlExcapedCode, yearFrom, monthFrom, dayFrom, yearTo, monthTo, dayTo ];
	NSLog( @"%@", s );
	return [ NSURL URLWithString: s ];

//	NSString* urlExcapedCode = [ code stringByReplacingOccurrencesOfString: @"=" withString: @"%3D" ];
//	return [ NSURL URLWithString: [ NSString stringWithFormat:
//		@"http://table.yahoo.co.jp/t?c=%d&a=%d&b=%d&f=%d&d=%d&e=%d&g=d&s=%@&y=0&z=%@&x=sb",
//		yearFrom, monthFrom, dayField, yearTo, monthTo, dayTo, urlExcapedCode, urlExcapedCode ] ];
}

- (BOOL) collectWithCode0: (NSString*) code0 
	code1: (NSString*) code1
	andMarketDataType: (MarketData::Type) type 
	intoStrings: (NSMutableArray*) htmlStrings;
{
	return [ super collectWithCode0: code0 code1: code1 andMarketDataType: MarketData::Type_CurrencyExchangeJa intoStrings: htmlStrings ];
}

@end
